package gold.digger;

import gold.utils.InputUtil;

import java.util.TreeMap;

/**
 * Created by fanzhenyu02 on 2021/12/10.
 * common problem solver template.
 */
public class LC1331 {
    public long startExecuteTime = System.currentTimeMillis();


    class Solution {
        public int[] arrayRankTransform(int[] arr) {
            TreeMap<Integer, Integer> cntMap = new TreeMap<>();
            for (int num : arr) {
                cntMap.put(num, 1);
            }

            int counter = 1;
            for (Integer num : cntMap.keySet()) {
                cntMap.put(num, counter++);
            }

            for (int i = 0; i < arr.length; i++) {
                arr[i] = cntMap.get(arr[i]);
            }

            return arr;
        }
    }

    public void run() {
        int[] arr = InputUtil.toIntegerArray("[1,2,3]");
        System.out.println(new Solution().toString());
    }

    public static void main(String[] args) throws Exception {
        LC1331 an = new LC1331();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
